package com.qili.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qili.entity.supplier.dto.OaReDTO;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;

/**
 * @author zhaoyongke
 * @date 2021/4/17
 * @description
 */
public class OaInfoUtil {

    public static String  key="WeaverOA";
    public static String contentType = "application/json; charset=UTF-8";
    /**
    * @Author:zhaoyongke
    * @Description: 查询oa 信息接口
    * @param
    * @Date:11:09 2021/4/17
    */
    public static OaReDTO queryOa(String params)  throws Exception {
        if(StringUtils.isBlank(params)){
            JSONObject jsonObject = new JSONObject();
            params = jsonObject.toJSONString();
        }
        Date date = new Date();
        long time = date.getTime();
        String sign1 = Md5Util.getBit32(time + key);
        String sign2 = Md5Util.getBit32(sign1);
        String sign3 = Md5Util.getBit32(sign2);
        String generalUrl = "http://oa.sdzz.cn/weaverjn/api/GetHtInfo.jsp?timestamp=" + time + "&sign=" + sign3;
        String result = HttpUtil.getGeneralUrl(generalUrl, contentType, params, "UTF-8");

        System.out.println(result);
        OaReDTO oaReDTO = JSON.parseObject(result, OaReDTO.class);
        return  oaReDTO;
    }

    public static void main(String[] args) {
        try {
            OaInfoUtil.queryOa("");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
